import json

import requests

login_url = 'http://www.haloncloud.top/login/'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36',
    'Accept': 'application/json'
}

login_dat = {'username': '18512344321', 'password': '11111111', 'remembered': True}

ss = requests.session()
# 生成session类的对象
# 后面所有的请求所有session对象请求
# 会自动保存cookie 然后请求的时候会自动上传cookie

response = ss.post(login_url, headers=headers, data=json.dumps(login_dat))
print(response.content.decode('utf-8'))

#
# # 把 RequestsCookieJar转为字典
# cookie_dict = requests.utils.dict_from_cookiejar(response.cookies)
# print(cookie_dict)

# 第二部分
# 获取个人中心数据
info_url = 'http://www.haloncloud.top/info/'
info_response = ss.get(info_url)
print(info_response.content.decode('utf-8'))
